package com.yls.except.util;
/**
 * xs
 * @author Administrator
 *
 */
public class PageModel {
	private int totalRecords;
	private int pageNumber;
	private int pageRecords;
	
	public PageModel(int pageNumber, int pageRecords,int totalRecords) {
		this.pageNumber = pageNumber;
		this.pageRecords = pageRecords;
		this.totalRecords = totalRecords;
		if(this.pageNumber > getTotalPages()){
			this.pageNumber = getTotalPages();
		} else if (this.pageNumber < 1){
			this.pageNumber = 1;
		}
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public int getPageRecords() {
		return pageRecords;
	}

	public void setPageRecords(int pageRecords) {
		this.pageRecords = pageRecords;
	}

	public int getTotalPages(){
		return (totalRecords-1)/pageRecords + 1;
	}
	public int getStartRecord(){
		return (pageNumber - 1) * pageRecords;
	}
}
